﻿using AutoRegistDependency.Attributes;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Core.Confignations
{
    [Configuration]
    public class SugarConfignation
    {
        [Bean]
        public ISqlSugarClient GetSqlSugarClient([Value("SqlSugarConfig")]ConnectionConfig config)
        {
            if (config.DbType == DbType.Sqlite)
            {
                var path = $"{AppDomain.CurrentDomain.BaseDirectory}Db\\handy.db";
                config.ConnectionString = string.Format(config.ConnectionString, path);
            }
            ISqlSugarClient client = new SqlSugarClient(config);
            return client;
        }
    }
}
